<template>
    <div class="st">
        <h2>学生姓名：{{name}}</h2>
        <h2>学生年龄：{{sex}}</h2>
        <h2>学生年龄：{{age}}</h2>
        <h2>当前num值：{{num}}</h2>
        <button @click="sendmsg">点我给School组件传递学生名字</button>
    </div>
</template>

<script>
import pubsub from 'pubsub-js'

//export default默认暴露，export分别暴露，export{}最后写，统一暴露
export default {   //一般用默认暴露
    // 指定标签名
    name:'Student',
    data() {
        return {
            msg:'你好同学！',
            name:'菜菜',
            sex:'女',
            age:18,
            num:1
        }
    },
    methods: {
        sendmsg(){
            // 发送消息，传递数据
            pubsub.publish('hello',this.name)
        }
    },
}

</script>

<style>
    .st{
        background-color:hotpink;
    }
</style>